package com.dpkit.adapter.orm.definition;

import java.util.Map;

/**
 * 字段定义
 */
public class FieldDefinition {

    private String fieldName;
    private FieldType fieldType;
    private Class<?> javaType;
    
    // 通用属性
    private boolean isId;
    private EntityDefinition.IdGenerationStrategy idGenerationStrategy;
    private boolean nullable = true;
    private Integer length;
    
    // ORM特定配置
    private Map<String, Object> jpaConfig;
    private Map<String, Object> mybatisConfig;

    /**
     * 是否关联字段
     */
    public boolean isAssociation() {
        return fieldType == FieldType.EMBEDDED || 
               fieldType == FieldType.ASSOCIATION;
    }


    // Getters and Setters
    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public FieldType getFieldType() {
        return fieldType;
    }

    public void setFieldType(FieldType fieldType) {
        this.fieldType = fieldType;
    }

    public Class<?> getJavaType() {
        return javaType;
    }

    public void setJavaType(Class<?> javaType) {
        this.javaType = javaType;
    }

    public boolean isId() {
        return isId;
    }

    public void setId(boolean id) {
        isId = id;
    }

    public EntityDefinition.IdGenerationStrategy getIdGenerationStrategy() {
        return idGenerationStrategy;
    }

    public void setIdGenerationStrategy(EntityDefinition.IdGenerationStrategy idGenerationStrategy) {
        this.idGenerationStrategy = idGenerationStrategy;
    }

    public boolean isNullable() {
        return nullable;
    }

    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }

    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    public Map<String, Object> getJpaConfig() {
        return jpaConfig;
    }

    public void setJpaConfig(Map<String, Object> jpaConfig) {
        this.jpaConfig = jpaConfig;
    }

    public Map<String, Object> getMybatisConfig() {
        return mybatisConfig;
    }

    public void setMybatisConfig(Map<String, Object> mybatisConfig) {
        this.mybatisConfig = mybatisConfig;
    }
}